﻿#ifndef _H264STREAM_H_
#define _H264STREAM_H_

#include <vector>
#include <string>
#include <stdint.h>

#define NALU_TYPE_SLICE     1
#define NALU_TYPE_DPA       2
#define NALU_TYPE_DPB       3
#define NALU_TYPE_DPC       4
#define NALU_TYPE_IDR       5
#define NALU_TYPE_SEI       6
#define NALU_TYPE_SPS       7
#define NALU_TYPE_PPS       8
#define NALU_TYPE_AUD       9
#define NALU_TYPE_EOSEQ     10
#define NALU_TYPE_EOSTREAM  11
#define NALU_TYPE_FILL      12



/*
 *            sodb + rbsp(trailing bits) = rbsp
 *            nalu header（1bytes） + rbsp = nalu
 *            startcode + nalu +startcode + nalu+ startcode.....=h264
 *
 *
 */


class CH264StreamFile
{
public:
    CH264StreamFile(char *fileName);
    ~CH264StreamFile();

	//Open API
    int ParseH264Bitstream();

private:
	FILE	*m_inputFile;
    std::string m_fileName;
    std::vector<uint8_t> m_nalVec;


	int		find_nal_prefix();
	void	ebsp_to_sodb();

};


#endif
